//
//  JGRealOrderAlertView.m
//  JGRider
//
//  Created by 单启志 on 2018/3/1.
//  Copyright © 2018年 ffq. All rights reserved.
//

#import "JGRealOrderAlertView.h"
#import "WJYAlertView.h"
@interface JGRealOrderAlertView()
@property (weak, nonatomic) IBOutlet UIImageView *typeImageView;
@property (weak, nonatomic) IBOutlet UILabel *messageLab;
@property (weak, nonatomic) IBOutlet UIButton *confirmBtn;

@end

@implementation JGRealOrderAlertView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self=[super initWithFrame:frame]) {
        self=[[[NSBundle mainBundle]loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil]lastObject];
        self.frame=frame;
        [self configSubViews];
    }
    return self;
}

-(void)awakeFromNib{
    [super awakeFromNib];


}

-(void)configSubViews{

    self.layer.cornerRadius=AdaptedHeight(3);
    self.layer.masksToBounds=YES;

    self.confirmBtn.layer.cornerRadius=AdaptedHeight(12.5);
    self.confirmBtn.layer.masksToBounds=YES;
    self.confirmBtn.layer.borderColor=HEXCOLOR(0xfea129).CGColor;
    self.confirmBtn.layer.borderWidth=AdaptedHeight(0.5);
}

-(void)layoutSubviews{
    [super layoutSubviews];
}

//确定
- (IBAction)onConfirmBtnClick:(id)sender {

    if (self.confirmBlock) {
        self.confirmBlock();
    }
//    if ([self.delegate respondsToSelector:@selector(alertViewConfirmEvent)]) {
//        [self.delegate alertViewConfirmEvent];
//    }
    WJYAlertView *alertView= (WJYAlertView*)self.superview;
    [alertView dismissWithCompletion:nil];
}

//关闭
- (IBAction)onCloseBtnClick:(id)sender {

   WJYAlertView *alertView= (WJYAlertView*)self.superview;
    [alertView dismissWithCompletion:nil];
}

-(void)setType:(ResulType)type{
    _type=type;
    switch (type) {
        case ResultTypeNoValidate:
            self.typeImageView.image=[UIImage imageNamed:@"window_icon_check"];
            self.messageLab.text=@"作进一步请先身份验证";
            [self.confirmBtn setTitle:@"马上验证" forState:UIControlStateNormal];
            break;
        case ResultTypeSuccess:
            self.typeImageView.image=[UIImage imageNamed:@"window_icon_success"];
            self.messageLab.text=@"抢单成功！请尽快处理";
            [self.confirmBtn setTitle:@"确定" forState:UIControlStateNormal];
            break;
        case ResultTypeWasRobbed:
            self.typeImageView.image=[UIImage imageNamed:@"window_icon_fail"];
            self.messageLab.text=@"抢单失败，改订单已被抢";
            [self.confirmBtn setTitle:@"确定" forState:UIControlStateNormal];
            break;

        default:
            break;
    }
}

@end
